home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mac Magazin/MacEasy 1
/
Mac Magazin and MacEasy Magazine CD - Issue 01.iso
/
Sharewarebibliothek
/
Powermac
/
C64
/
SOURCE
/
Register.c
< prev
next >
Wrap
Text File
|
1994-06-06
|
3KB
|
111 lines
/*
Commodore 64 Emulator v0.4 Earle F. Philhower III
Copyright (C) 1993-4 (st916w9r@dunx1.ocs.drexel.edu)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "Processor.h"
#include "FileTypes.h"
#include "Error.h"
#include "Preferences.h"
#include "Resources.h"
extern int programMode;
extern Cursor commieCursor, diskCursor;
word pc;
byte a, x, y, flags, sp;
int RegisterInitialize()
{
RAM[0]=RAM[1]=63;
if (globalPref.ramCheck==0) hiROM[0x1d69]=0x9d;
else hiROM[0x1d69]=0x04;
SetUpMemoryMap();
pc=WordAt(ResetTo);
sp=255;
flags=4;
return kNoError;
}
void SaveRAMFS(FSSpec *spec)
{
short fnum;
long len;
FSpCreate(spec, (OSType)APPLTYPE, (OSType)RAMFTYPE, 0);
FSpOpenDF(spec, fsRdWrPerm, &fnum);
len=sizeof(word); FSWrite(fnum, &len, &pc);
len=sizeof(byte); FSWrite(fnum, &len, &a);
len=sizeof(byte); FSWrite(fnum, &len, &x);
len=sizeof(byte); FSWrite(fnum, &len, &y);
len=sizeof(byte); FSWrite(fnum, &len, &flags);
len=sizeof(byte); FSWrite(fnum, &len, &sp);
len=65536; FSWrite(fnum, &len, RAM);
FSClose(fnum);
}
void LoadRAMFS(FSSpec *spec)
{
short fnum;
long len;
FSpOpenDF(spec, fsRdPerm, &fnum);
len=sizeof(word); FSRead(fnum, &len, &pc);
len=sizeof(byte); FSRead(fnum, &len, &a);
len=sizeof(byte); FSRead(fnum, &len, &x);
len=sizeof(byte); FSRead(fnum, &len, &y);
len=sizeof(byte); FSRead(fnum, &len, &flags);
len=sizeof(byte); FSRead(fnum, &len, &sp);
len=65536; FSRead(fnum, &len, RAM);
FSClose(fnum);
TotalRedrawVIC();
}
void SaveRAM(void)
{
StandardFileReply reply;
StandardPutFile("\pSave RAM Image:", "\pRAM", &reply);
if (reply.sfGood)
{
SetCursor(&diskCursor);
SaveRAMFS(&(reply.sfFile));
}
if (programMode==kRunning) SetCursor(&commieCursor);
else SetCursor(&qd.arrow);
}
void LoadRAM(void)
{
StandardFileReply reply;
StandardGetFile(nil, (short)-1, nil, &reply);
if (reply.sfGood)
{
SetCursor(&diskCursor);
LoadRAMFS(&(reply.sfFile));
}
if (programMode==kRunning) SetCursor(&commieCursor);
else SetCursor(&qd.arrow);
}